package com.project.user.server;

import com.project.user.entity.entitly.LoginToken;
import com.project.user.entity.entitly.UserInfo;
import com.project.user.entity.entitly.UserInformationView;
import com.untils.Resultant;

public interface UserServer {

    /**
     * user login server code
     * @param phone username
     * @param password user-password
     * @param loginIpv4 ipv4
     * @param loginIpaddress  address
     * @return user-login-successfully json
     * @throws Exception sqlExample
     * - is-successfully : true/false
     * - message: StaticMessage.CREATE_PHONE_REQUEST_MESSAGE/StaticMessage.CREATE_PHONE_EXAMPLE_MESSAGE
     */
    Resultant phonePasswordLogin(String phone, String password,String loginIpv4, String loginIpaddress) throws Exception;

    /**
     * get user phone code
     * @param phone user-phone
     * @param phoneCode user-password
     * @param loginIpv4 ipv4
     * @param loginIpaddress  address
     * @return get user phone code successfully
     * @throws Exception sqlExample
     */
    Resultant phoneCodeLogin(String phone, String phoneCode, String loginIpv4, String loginIpaddress) throws Exception;

    /**
     * set user phone code
     * @param phone user phone
     * @return set user phone code successfully
     */
    Resultant setUserPhoneCode(String phone);

    /**
     * get user info
     * @param session user session
     * @return get user info
     */
    Resultant getUInformation(String session);

    /**
     * sign out for user login
     * @param session user session
     * @return sign out for user
     */
    Resultant signOut(String session);

    /**
     * get user info
     * @param session user session
     * @return user info
     * @throws Exception sqlExample
     */
    UserInformationView getUInfo(String session) throws Exception;

    /**
     * update user info
     * @param session user session
     * @param user user info
     * @return update user info
     */
    Resultant updateUserInfo(String session, UserInfo user);

    /**
     * insert into user-table
     * @param username user-name
     * @param password user-password
     * @return insert into user-table successfully
     */
    Resultant instepUserInfo(String username, String password);

    /**
     * user is not  login
     * @param phone user phone
     * @param userIpV4 user ipv4 address
     * @return true/false
     */
    boolean userIsLoginEd(String phone, String userIpV4);

    /**
     * get user token object
     * @param phone user phone
     * @return get user token object
     */
    LoginToken userTokenGet(String phone) throws Exception;

}
